/**
 * 测试WritableComparator
 * 主要获得特定类型的Writable比较器
 * 
 */
package com.tjh.hadoop.writable;

import static org.junit.Assert.assertThat;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.RawComparator;
import org.apache.hadoop.io.WritableComparator;
import org.hamcrest.Matchers;
import org.junit.Test;
/**
 * @author jahen
 * @date 2016年9月11日
 * @time 下午9:26:22
 * @category Hadoop Writable
 */
public class TestWritableComparator {
	/**
	 * 获得IntWritable类型的比较器Comparator
	 * 
	 * IntWritable类型之间的比较
	 */
	@Test
	public void testGetIntWritableComparator() throws Exception{
		@SuppressWarnings("unchecked")
		RawComparator<IntWritable> comparator = WritableComparator.get(IntWritable.class);
		IntWritable o1 = new IntWritable(12);
		IntWritable o2 = new IntWritable(41);
		assertThat(comparator.compare(o1, o2), Matchers.lessThan(0));
	}

}
